/*
 * Custom_Config.h
 *
 *  Created on: 2021��8��6��
 *      Author: vicent-PC
 */

#ifndef MAIN_CONFIG_H_
#define MAIN_CONFIG_H_

#include "driver/gpio.h"

// PROJECT DEFINE

// #define AI_THINK_PORJECT 1
// #define AI_THINK_BOARD_PORJECT 1
#define LOATOS_BOARD_PROJECT 2
#define BOARD_VENDOR (LOATOS_BOARD_PROJECT)

// ESP32 C3
#ifdef AI_THINK_PORJECT
#define IO0 (GPIO_NUM_0)  // used: KEY
#define IO1 (GPIO_NUM_1)
#define IO2 (GPIO_NUM_2)  // used: ADC tempreture
#define IO3 (GPIO_NUM_3)  // used: LED 红灯 //steering motor

#define IO4 (GPIO_NUM_4)  // used: LED 绿灯 //step motor
#define IO5 (GPIO_NUM_5)  // used: LED 蓝灯 //step motor
#define IO6 (GPIO_NUM_6)  // used: SPI //step motor
#define IO7 (GPIO_NUM_7)  // used: SPI //step motor

#define IO8 (GPIO_NUM_8)  // used:i2c SDA->
#define IO9 (GPIO_NUM_9)  // used: KEY
#define IO10 (GPIO_NUM_10)
#define IO18 (GPIO_NUM_18)  // used:i2c  SCL-> (LED 黄灯)
#define IO19 (GPIO_NUM_19)  // not used: LED 白灯
#define IO20 (GPIO_NUM_20)
#define IO21 (GPIO_NUM_21)
#elif defined LOATOS_BOARD_PROJECT
#define IO2 GPIO_NUM_2  // SCL->
#define IO3 GPIO_NUM_3  // SDA->

#define IO4 (GPIO_NUM_4)  // pwm
#define IO5 (GPIO_NUM_5)  //
#define IO6 (GPIO_NUM_6)  //
#define IO7 (GPIO_NUM_7)  //

#define IO8 (GPIO_NUM_8)  // used: unknow, not available
#define IO9 (GPIO_NUM_9)  // used: KEY BOOT
#endif

// I2C
#ifdef AI_THINK_BOARD_PORJECT
#define SCL_PIN GPIO_NUM_18  // SCL->
#define SDA_PIN GPIO_NUM_8   // SDA->
#else
#ifdef LOATOS_BOARD_PROJECT
#define SCL_PIN GPIO_NUM_2  // SCL->
#define SDA_PIN GPIO_NUM_3  // SDA->
#endif
#endif

// current detect
const float INA_SHUNT_R = 0.1;

// solar
// #define SOLOR_OUTPUT2SHUNT
#define BOOSTER_12V_OUTPUT2SHUNT 0
#define BOOSTER_5V_OUTPUT2SHUNT 1

#ifdef SOLOR_OUTPUT2SHUNT
const float SOLAR_ALLOW_RATIO =
    0.8;  // Allow work vol:  >= max_vol * SOLAR_ALLOW_RATIO
const float VOL_BOOSTER_LEVEL1_MIN_INPUT = 1.78;  // V
const float PWM_PERSENT_K = 10;                   // V
const float SOLAR_MAX_POWER = 7.5 * 2;            // W
const float SOLAR_BEST_VOL = 1.72 * 2;            // V
const float SOLAR_BEST_CUR = 4.56;                // A
const float SOLAR_MAX_VOL = 1.84 * 2;             // V
const float SOLAR_MAX_CUR = 4.84;                 // A
#elif BOOSTER_12V_OUTPUT2SHUNT
const float SOLAR_ALLOW_RATIO =
    0.91;  // Allow work vol:  >= max_vol * SOLAR_ALLOW_RATIO
const float VOL_BOOSTER_LEVEL1_MIN_INPUT = 11;  // V:11
const float PWM_PERSENT_UP_K = 500;             //
const float PWM_PERSENT_DOEN_K = 250;           //
#elif BOOSTER_5V_OUTPUT2SHUNT
// const float SOLAR_ALLOW_RATIO = 0.8 ;	// Allow work vol:  >= max_vol *
// SOLAR_ALLOW_RATIO
const float VOL_BOOSTER_LEVEL1_MIN_INPUT = 4;  // V:11
const float PWM_PERSENT_UP_K = 500;            //
const float PWM_PERSENT_DOEN_K = 250;          //
#endif

// voltage booster

class Config {
   public:
    Config();
    virtual ~Config();
};

#endif /* MAIN_CONFIG_H_ */
